package cn.edu.bupt.thymeleaf.examples.config;

import cn.edu.bupt.thymeleaf.examples.filter.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")  // 拦截所有请求
                .excludePathPatterns(
                        "/login",
                        "/register", // 排除登录和注册页面
                        "/static/**"  // 排除静态资源路径
                );
    }
}
